package com.bwie.home.backstage.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bwie.home.backstage.entity.TeamUserLogEntity;
import com.bwie.home.backstage.service.TeamUserLogService;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.R;



/**
 * 
 *
 * @author sy
 * @email sunlightcs@gmail.com
 * @date 2021-09-16 11:01:32
 */
@RestController
@RequestMapping("backstage/teamuserlog")
public class TeamUserLogController {
    @Autowired
    private TeamUserLogService teamUserLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = teamUserLogService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 获取指定拼团ID的参团成员列表
     */
    @GetMapping("/list/{id}")
    public R getListById(@RequestParam(value = "page",defaultValue = "1")int page,
                         @RequestParam(value = "limit",defaultValue = "2")int limit,@PathVariable int id){
        IPage<TeamUserLogEntity> pa = teamUserLogService.getListById(page,limit,id);

        return R.ok().put("page", pa);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		TeamUserLogEntity teamUserLog = teamUserLogService.getById(id);

        return R.ok().put("teamUserLog", teamUserLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TeamUserLogEntity teamUserLog){
		teamUserLogService.save(teamUserLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TeamUserLogEntity teamUserLog){
		teamUserLogService.updateById(teamUserLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		teamUserLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 删除对应的参团成员(逻辑删除)
     */
    @PutMapping("/delPinTeamBuy")
    public R dptb(@RequestBody Integer[] ids){
        teamUserLogService.dptb(Arrays.asList(ids));

        return R.ok();
    }

}
